package collection;

import java.util.ArrayList;
import java.util.Collection;

public class NewForDemo {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        System.out.println(c);
        //新循环会依次将每个元素赋值给变量e然后进入循环体
        for (String s : c){
            System.out.println(s);
        }
        String[] array = {"one","two","three","four","five"};
        for (int i = 0; i < array.length; i++) {
            String e =array[i];
            System.out.println(e);
        }
        //新循环遍历数组
        for (String e : array){
            System.out.println(e);
        }
    }
}
